//
//  ZTodoNotifyView.m
//  WeClubs
//
//  Created by Zed Link on 11/4/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "ZTodoNotifyView.h"
#import "ZTodoConfirmButton.h"
#import "ZClientInfoCenter.h"
#import "UIView+ZUtilities.h"
#import "NSDate+ZUtilities.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>


@interface ZTodoNotifyView ()

@property (weak, nonatomic) IBOutlet UIImageView *logoImgView;
@property (weak, nonatomic) IBOutlet UILabel *sponsorLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet ZTodoConfirmButton *confirmBtn;

@end

@implementation ZTodoNotifyView

- (void)zInitPrepare
{
    [super zInitPrepare];
    
    // ========== 阴影与圆角处理 ==========
    [self.logoImgView zCornerDeal:20];
    
    [self.confirmBtn setTitle:@"确认收到" forState:UIControlStateNormal];
    [self.confirmBtn setTitle:@"已确认收到" forState:UIControlStateSelected];
}

- (void)updateCell
{
    self.sponsorLabel.text = self.model.sponsor.sponsorName;
    self.contentLabel.text = self.model.content;
    self.dateLabel.text = [[ZClientInfoCenter sharedInstance] stringByFormatt:@"MM月dd日" fromMilliSeconds:self.model.createDate];
    
    NSString *urlStr = self.model.sponsor.sponsorAvator;
    if (urlStr != nil) {
        [self.logoImgView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
    }
}

#pragma mark - Control Action

- (IBAction)confirmBtnAction:(id)sender
{
    if (self.confirmBtn.selected == NO) {
        self.confirmBtn.selected = YES;
        self.confirmBtn.userInteractionEnabled = NO;
    }
}

#pragma mark - Getter & Setter

- (void)setModel:(ZTodoNotifyModel *)model
{
    _model = model;
    
    [self updateCell];
}

@end
